home *** CD-ROM | disk | FTP | other *** search
/ Champak 49 / Volume 49 - JOGO DISK .iso / Games / bloop.swf / scripts / DefineSprite_89_cannon / frame_1 / DoAction.as
Text File  |  2007-09-27  |  3KB  |  142 lines

  1. if(!setVars)
  2. {
  3.    oldX = _root._xmouse;
  4.    _root.setFrame(this);
  5.    oMoveSpeed = 4;
  6.    if(!_root.moveSpeed)
  7.    {
  8.       moveSpeed = oMoveSpeed;
  9.    }
  10.    else
  11.    {
  12.       moveSpeed = _root.moveSpeed;
  13.    }
  14.    xPos = _X;
  15.    friction = 20;
  16.    minX = 50;
  17.    maxX = Stage.width - 50;
  18.    var noPress;
  19.    bbarws = bbar.bar._width;
  20.    setVars = true;
  21. }
  22. onEnterFrame = function()
  23. {
  24.    _root.checkFrame(this);
  25.    if(!_root.moveSpeed)
  26.    {
  27.       moveSpeed = oMoveSpeed;
  28.    }
  29.    else
  30.    {
  31.       moveSpeed = _root.moveSpeed;
  32.    }
  33.    if(_root.mw == "mouse")
  34.    {
  35.       if(_root._xmouse > oldX)
  36.       {
  37.          f1._visible = true;
  38.          f1._alpha += 10;
  39.          f1.play();
  40.          xPos = _root._xmouse;
  41.       }
  42.       else
  43.       {
  44.          f1.gotoAndStop(21);
  45.          f1._alpha -= 10;
  46.       }
  47.       if(_root._xmouse < oldX)
  48.       {
  49.          f2._visible = true;
  50.          f2._alpha += 10;
  51.          f2.play();
  52.          xPos = _root._xmouse;
  53.       }
  54.       else
  55.       {
  56.          f2.gotoAndStop(21);
  57.          f2._alpha -= 10;
  58.       }
  59.       oldX = _root._xmouse;
  60.    }
  61.    else
  62.    {
  63.       if(Key.isDown(39))
  64.       {
  65.          f1._visible = true;
  66.          f1._alpha += 10;
  67.          f1.play();
  68.          xPos += moveSpeed;
  69.       }
  70.       else
  71.       {
  72.          f1.gotoAndStop(21);
  73.          f1._alpha -= 10;
  74.       }
  75.       if(Key.isDown(37))
  76.       {
  77.          f2._visible = true;
  78.          f2._alpha += 10;
  79.          f2.play();
  80.          xPos -= moveSpeed;
  81.       }
  82.       else
  83.       {
  84.          f2.gotoAndStop(21);
  85.          f2._alpha -= 10;
  86.       }
  87.    }
  88.    _X = _X + (xPos - _X) / friction;
  89.    if(_X > maxX)
  90.    {
  91.       _X = maxX - 1;
  92.       xPos = _X;
  93.    }
  94.    if(_X < minX)
  95.    {
  96.       _X = minX + 1;
  97.       xPos = _X;
  98.    }
  99.    keyNum = 65;
  100.    while(keyNum < 90)
  101.    {
  102.       if(Key.isDown(keyNum))
  103.       {
  104.          if(_root.nextShot >= 100)
  105.          {
  106.             _root.nextShot = 0;
  107.             _root.depth = _root.depth + 1;
  108.             _root.attachMovie("bullet","bullet" + _root.depth,_root.depth);
  109.             eval("_root.bullet" + _root.depth).moveSpeed = 3;
  110.             eval("_root.bullet" + _root.depth).letternum = keyNum + 1;
  111.             eval("_root.bullet" + _root.depth)._alpha = 50;
  112.             eval("_root.bullet" + _root.depth)._x = _X;
  113.             eval("_root.bullet" + _root.depth)._y = _Y - 20;
  114.             eval("_root.bullet" + _root.depth)._width = _root.bubblesize;
  115.             eval("_root.bullet" + _root.depth)._height = _root.bubblesize;
  116.          }
  117.       }
  118.       keyNum++;
  119.    }
  120.    if(_root.rapidcount > 0)
  121.    {
  122.       plus = 20;
  123.    }
  124.    else
  125.    {
  126.       plus = 5;
  127.    }
  128.    if(_root.nextShot < 100)
  129.    {
  130.       _root.nextShot += plus;
  131.    }
  132.    if(_root.nextShot > 100)
  133.    {
  134.       _root.nextShot = 100;
  135.    }
  136.    if(_root.nextShot < 0)
  137.    {
  138.       _root.nextShot = 0;
  139.    }
  140.    bbar.bar._width = _root.nextShot * bbarws / 100;
  141. };
  142.